package com.itheima.controller;


import com.itheima.manager.TitleManager;
import com.itheima.soul.OptionsAll;
import com.itheima.soul.TitleVo;
import jdk.nashorn.internal.ir.IfNode;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static com.baomidou.mybatisplus.core.toolkit.IdWorker.getId;

@RestController
public class TitleController {


    @Autowired
    TitleManager titleManager;

    /**
     * 分页查询灵魂测试题目
     *
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/soul/title")
    public ResponseEntity findTitleAll(@RequestParam(defaultValue = "1") Integer pageNum,
                                       @RequestParam(defaultValue = "10") Integer pageSize,
                                       Integer cid,String keyword) {
        return titleManager.findTitleAll(pageNum, pageSize,cid,keyword);

    }

    @GetMapping("/soul/optins")
    public ResponseEntity findOptinsById(Long id) {
        return titleManager.findOptinsById(id);
    }


    @PostMapping("/soul/save")
    public ResponseEntity saveAndupdate(@RequestBody OptionsAll titleVo) {



            return titleManager.save(titleVo);

    }
    @PostMapping("/soul/update")
    public ResponseEntity update(@RequestBody TitleVo titleVo) {


        return titleManager.update(titleVo);

    }
    @GetMapping("/soul/delete")
    public ResponseEntity delete(Long id) {


        return titleManager.delete(id);

    }


    @GetMapping("/soul/deletes")
    public ResponseEntity deletes(Integer[] ids) {


        return titleManager.deletes(ids);

    }
}
